<script setup>
import { onMounted, ref } from 'vue';
import { uniFetch } from '../../../utils/fetch';
	onMounted(()=>{
		// getlist()
	})
	const list=ref([]);
	const page=ref(1);
	const size=ref(10);
	const scrolltolower=()=>{
		console.log(123333444);
		getlist()
	}
	const refreshtrigger=ref(true)
	const xlsx=()=>{
		console.log("下拉刷新");
		refreshtrigger.value=true
		list.value=[];
		page.value=1;
		getlist()
		
		console.log(refreshtrigger.value);
	}
	const tihuo=(e)=>{
		uni.navigateTo({
			url:"/subpkg_task/detail/index?id="+e
		})
	}
	const getlist=()=>{
		uniFetch({
			url:"/driver/tasks/list",
			data:{
				page:page.value,
				pageSize:size.value,
				status:1
			}
		}).then(res=>{
			console.log(res,"res");
			if(res.data.data.items !== null){
		list.value=[...list.value,...res.data.data.items]
			page.value+=1;				
			}else{
				// list.value=[...list.value,...[]];
				uni.showToast({
					icon:"none",
					title:"暂无更多数据"
				})	
			}

			refreshtrigger.value=false
		})
	}
	
</script>

<template>
  <scroll-view scroll-y refresher-enabled :refresher-triggered="refreshtrigger" @refresherrefresh="xlsx" class="scroll-view" @scrolltolower="scrolltolower">
    <view class="scroll-view-wrapper">
      <view class="task-card" v-for="(item,index) in list">
        <navigator hover-class="none" :url="'/subpkg_task/detail/index?id='+item.id">
          <view class="header">
            <text class="no">任务编号: {{item.transportTaskId}}</text>
           <!-- <text class="status">已延迟</text> -->
          </view>
          <view class="body">
            <view class="timeline">
              <view class="line"
                >{{item.startAddress}}</view
              >
              <view class="line">{{item.endAddress}}</view>
            </view>
          </view>
        </navigator>
        <view class="footer">
          <view class="label">提货时间</view>
          <view class="time">{{item.planDepartureTime}}</view>
          <navigator
		  v-if="item.enablePickUp == true"
            hover-class="none"
            :url="'/subpkg_task/pickup/index?id='+item.id"
            class="action"
            >提货</navigator
          >
		      <button v-else disabled class="action" @click="tihuo(item.id)">提货</button>
        </view>
      </view>
     <!-- <view class="task-card">
        <navigator hover-class="none" url="/subpkg_task/detail/index?id=001">
          <view class="header">
            <text class="no">任务编号: XAHH1234567</text>
          </view>
          <view class="body">
            <view class="timeline">
              <view class="line"
                >北京市昌平区回龙观街道西三旗桥东金燕龙写字楼8877号</view
              >
              <view class="line">河南省郑州市路北区北清路99号</view>
            </view>
          </view>
        </navigator>
        <view class="footer">
          <view class="label">提货时间</view>
          <view class="time">2022.05.04 13:00</view>
          <button disabled class="action">提货</button>
        </view>
      </view> -->
      <view v-if="list.length == 0" class="task-blank">无待提货物</view>
    </view>
  </scroll-view>
</template>

<style lang="scss" scoped>
  @import './styles.scss';
</style>
